package com.xmkj.bearbiz.mine.adapter;

import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.widget.TextView;

import com.common.carbean.CarListBean;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearbiz.R;

import java.util.List;

/**
 * Created by chen on 2018/4/1.
 */

public class ChooseCarAdapter extends CommonAdapter<CarListBean.ListsEntity> {
    public ChooseCarAdapter(Context context, List<CarListBean.ListsEntity> data) {
        super(context, data);
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    protected void convert(ViewHolder holder, final CarListBean.ListsEntity item, int position) {
        holder.setText(R.id.tv_car_name, item.brand + " " + item.model + " " + item.color);
        holder.setText(R.id.tv_code, item.carnum);
        TextView tvDefault = holder.getView(R.id.tv_set_default);
        if (item.is_default == 2) {//默认的
            tvDefault.setTextColor(mContext.getColor(R.color.main_color));
            tvDefault.setBackground(mContext.getDrawable(R.drawable.tv_default));
        } else {
            tvDefault.setTextColor(mContext.getColor(R.color.black));
            tvDefault.setBackground(mContext.getDrawable(R.drawable.tv_del));
        }
        holder.setOnClickListener(R.id.tv_delete, new OnItemChildClickListener());
        holder.setOnClickListener(R.id.rl_choose, new OnItemChildClickListener());

    }

    @Override
    protected int getItemViewLayoutId(int position, CarListBean.ListsEntity item) {
        return R.layout.item_choose_car;
    }
}
